package com.icss.clothes.service.imp;

import com.icss.clothes.entity.Buy;
import com.icss.clothes.mapper.WishlistMapping;
import com.icss.clothes.service.IWishlistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WishlistService implements IWishlistService {
    @Autowired
    private WishlistMapping wishlistMapping;

    //添加收藏
    @Override
    public String addCollection(Buy buy) {
        Buy sameBuy=wishlistMapping.findSameCollection(buy);
        if(sameBuy!=null){
            return "该商品已收藏";
        }
            wishlistMapping.addCollection(buy);
            return "收藏成功";
    }

    //查看收藏
    @Override

    public List<Buy> lookCollection(int user_id) {
         return wishlistMapping.lookCollection(user_id);
    }
    //删除收藏
    @Override
    public void deleteCollection(int c_id, int user_id) {
        wishlistMapping.deleteCollection(c_id,user_id);
    }


}
